<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("path", basePath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

<title>购物车页面</title>

<link href="<%=path%>/web/assets/css/amazeui.css" rel="stylesheet"
	type="text/css" />
<link href="<%=path%>/web/basic/css/demo.css" rel="stylesheet"
	type="text/css" />
<link href="<%=path%>/web/css/cartstyle.css" rel="stylesheet"
	type="text/css" />
<link href="<%=path%>/web/css/optstyle.css" rel="stylesheet"
	type="text/css" />

<%-- <script type="text/javascript" src="<%=path%>/web/js/jquery.js"></script> --%>
<script type="text/javascript" src="<%=path%>/web/js/jquery-2.2.4.js"></script>
<script type="text/javascript">

function decreaseNum(id,commodityId){
	  var num = $(".text_box"+id).val();  	 
	  num--;
	  
if(num>=1){
 //Ajax调用处理
 jQuery.ajax({
     type: "POST",
     url: "<%=path%>/shopcar/shopcartcutNum.do?id="+id+"&commodityId="+commodityId,
     dataType:"json",
     success: function(data){
             // $("#myDiv").html('<h2>result'+data.success+'</h2>');
        },
 error:function(){
	 alert("操作失败"); 
  }
  });

     var price = $("#priceOne"+id).html();
     $("#allPrice"+id).attr("value",num*price);
     $(".text_box"+id).attr("value",num);
     
     var allN = $(".allNum"+id).val();
     allN++;
     $(".allNum"+id).attr("value",allN);
 }
}

function increaseNum(id,commodityId){
	//alert("123");
 //Ajax调用处理
 jQuery.ajax({
     type: "POST",
     url: "<%=path%>/shopcar/shopcartAddNum.do?id="+id+"&commodityId="+commodityId,
     dataType:"json",
     success: function(data){
              //$("#myDiv").html('<h2>result'+data.success+'</h2>');
        },
     error:function(){
      	 alert("操作失败"); 
        }
  });
 var num = $(".text_box"+id).val();   
 num++;
// alert(num);
 var price = $("#priceOne"+id).html();
// alert(price);
 $("#allPrice"+id).attr("value",num*price);
 $(".text_box"+id).attr("value",num);
 
 var allN = $(".allNum"+id).val();
 allN--;
 $(".allNum"+id).attr("value",allN);
 
}

  function allMoney(){
    	
	       var items = $('input[name="itemsFlag"]');
           var money = $("[name='money']");
           var len = items.length;
          
           var all =0;
           for(var i=0;i<len;i++){
        	   if(items[i].checked){
        		   all=all+Number(money[i].value);
        		   //alert(items[i].value);
        	   }
           }
         /*   $.each( money, function(i, n){
        	   //alert($(this).val());
        	  all=all+Number($(this).val());
        	 });
           $.each( items, function(i, n){
        	   alert($(this).is(':checked'));
        	  
        	 }); */
           $("#J_Total").attr("value",all);
           //alert(all);
          // $('input[name="jidlist"]:checked'
    }
  function checkAll(ele) {    
	/*   alert(ele.checked);
	 var item = $("#selectALL").is(':checked');
	 alert(item); */
	 $("input[name='itemsFlag']").prop("checked", ele.checked);    
	 allMoney();  
	     
   }
  
  function formSubmit(){
	  var items = $('input[name="itemsFlag"]');
      var len = items.length;
     
      var c =0;
      for(var i=0;i<len;i++){
   	   if(items[i].checked){
   		  c++;
   	   }
      }
      if(c>0){
    	  $("#orderSubmit").submit();
      }else{
    	  alert("请选择商品！");
      }
	 
  }

</script>
</head>

<body>
	<!-- <div id="myDiv"></div> -->
	
	<!--顶部导航条 -->
	<div class="am-container header">
			<ul class="message-l">
				<div class="topMessage">
					<div class="menu-hd">
					<c:choose> 
					<c:when test="${userInfoSession!=null}">
					  <a href="<%=path %>/web/user/login.jsp" target="_top" class="h">欢迎${userInfoSession.userName}</a> 
					
					</c:when>
					<c:otherwise>
						<a href="<%=path %>/web/user/login.jsp" target="_top" class="h">亲，请登录</a> 
						<a href="<%=path %>/web/user/signUp.jsp" target="_top">免费注册</a>
					</c:otherwise>
					</c:choose>
					</div>
				</div>
			</ul>
			<ul class="message-r">
				<div class="topMessage home">
					<div class="menu-hd">
						<a href="<%=path %>/adv/queryAdvWeb.do" target="_top" class="h">商城首页</a>
					</div>
				</div>
				<div class="topMessage my-shangcheng">
					<div class="menu-hd MyShangcheng">
						<a href="<%=path %>/web/user/person.jsp" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a>
					</div>
				</div>
				<div class="topMessage mini-cart">
					<div class="menu-hd">
						<a id="mc-menu-hd" href="<%=path %>/shopcar/queryShopcarInfo.do" target="_top"><i
							class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span></a>
					</div>
				</div>
				<div class="topMessage favorite">
					<div class="menu-hd">
						<a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a>
					</div>
			</ul>
		</div>

	<!--悬浮搜索框-->

	<div class="nav white">
		<div class="logo">
			<img src="<%=path%>/web/images/logo.png" />
		</div>
		<div class="logoBig">
			<li><img src="<%=path%>/web/images/logobig.png" /></li>
		</div>

		<div class="search-bar pr">
			<a name="index_none_header_sysc" href="#"></a>
			<form action="<%=path%>/commodity/queryCommodityWeb.do"
					method="post">
					<input id="searchInput" name="name" type="text" placeholder="搜索"
						autocomplete="off"> <input id="ai-topsearch"
						class="submit am-btn" value="搜索" index="1" type="submit">
		   </form>
		</div>
	</div>

	<div class="clear"></div>

	<!--购物车 -->
	<div class="concent">
		<div id="cartTable">
			<div class="cart-table-th">
				<div class="wp">
					<div class="th th-chk">
						<div id="J_SelectAll1" class="select-all J_SelectAll"></div>
					</div>
					<div class="th th-item">
						<div class="td-inner">商品信息</div>
					</div>
					<div class="th th-price">
						<div class="td-inner">单价</div>
					</div>
					<div class="th th-amount">
						<div class="td-inner">数量</div>
					</div>
					<div class="th th-sum">
						<div class="td-inner">金额</div>
					</div>
					<div class="th th-op">
						<div class="td-inner">操作</div>
					</div>
				</div>
			</div>
			<div class="clear"></div>

			<tr class="item-list">
				<div class="bundle  bundle-last ">
					<div class="bundle-hd"></div>
					<div class="clear"></div>
					<div class="bundle-main">
					<form action="<%=path %>/subOrder/getOrder.do?" method="post" id="orderSubmit">
						<c:forEach items="${requestScope.shopCarList}" var="sc">
						    <%-- <input type="checkbox" name="shopCarL" value="${sc.id }" /> --%>
							<li>
                               
								<ul class="item-content clearfix">
									<li class="td td-chk">
										<div class="cart-checkbox ">
											<input class="check" name="itemsFlag"  type="checkbox"	onclick="allMoney()" value="${sc.commodityId},${sc.num},${sc.id }">
												<label for="J_CheckBox_170037950254"></label>
										</div>
									</li>
									<li class="td td-item">
										<div class="item-pic">
											<a
												href="<%=path %>/commodity/queryCommodityWeb.do?id=${sc.commodityId}&detail=1"
												target="_blank" data-title="美康粉黛醉美东方唇膏口红正品 持久保湿滋润防水不掉色护唇彩妆"
												class="J_MakePoint" data-point="tbcart.8.12"> <img
												src="<%=path%>/Imgs/${sc.imgName}" class="itempic J_ItemImg"
												width="80px;" height="80px;"></a>
										</div>
										<div class="item-info">
											<div class="item-basic-info">
												<a
													href="<%=path %>/commodity/queryCommodityWeb.do?id=${sc.commodityId}&detail=1"
													target="_blank" title="美康粉黛醉美唇膏 持久保湿滋润防水不掉色"
													class="item-title J_MakePoint" data-point="tbcart.8.11">${sc.commodityName }</a>
											</div>
										</div>
									</li>
									<li class="td td-info">
										<div class="item-props item-props-can"></div>
									</li>
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">
												<div class="price-line">
													<em class="price-original">${sc.price }</em>
												</div>
												<div class="price-line">

													<em class="J_Price price-now" id="priceOne${sc.id }"
														tabindex="0">${sc.price*sc.discount }</em>
												</div>
											</div>
										</div>
									</li>
									<li class="td td-amount">
										<div class="amount-wrapper ">
											<div class="item-amount ">
												<div class="sl">
													<input class="min am-btn" name="" type="button" value="-"
														onclick="decreaseNum(${sc.id},${sc.commodityId})" /> 
												    <input	class="text_box${sc.id }" name="" type="text"
														value="${sc.num }" style="width: 30px;" /> 
													<input	class="add am-btn" name="" type="button" value="+"
														onclick="increaseNum(${sc.id},${sc.commodityId})" />
														<p>库存：<input class="allNum${sc.id }" value="${sc.allNum}" style="border-style:none; width: 20px;"/></p>
												</div>
												
											</div>
										</div>
									</li>
									<li class="td td-sum">
										<div class="td-inner">
											<input class="J_ItemSum_number" type="text" name="money"
												id="allPrice${sc.id }" value="${sc.price*sc.num*sc.discount*1 }"
												style="border: none;" />
										</div>
									</li>
									<li class="td td-op">
										<div class="td-inner">
											<!-- <a title="移入收藏夹" class="btn-fav" href="#">   移入收藏夹</a> -->
											<a href="<%=path %>/shopcar/deleteShopCarInfo.do?id=${sc.id}" data-point-url="#" class="delete">
												删除</a>
										</div>
									</li>
								</ul>
						</c:forEach>

                     
					</div>
				</div>
			</tr>
			<div class="clear"></div>


		</div>
		<div class="clear"></div>

		<div class="float-bar-wrapper">
			<div id="J_SelectAll2" class="select-all J_SelectAll">
				<div class="cart-checkbox">
					<input class="check-all check" id="selectAll"
						name="selectAll"  type="checkbox"
						onclick="checkAll(this)" />
				
				</div>
				<span>全选</span>
			</div>
			<div class="operations">
				<a href="#" hidefocus="true" class="deleteAll">删除</a> <a href="#"
					hidefocus="true" class="J_BatchFav">移入收藏夹</a>
			</div>
			<div class="float-bar-right">
				<div class="amount-sum">
					<span class="txt">已选商品</span> <em id="J_SelectedItemsCount">0</em><span
						class="txt">件</span>
					<div class="arrow-box">
						<span class="selected-items-arrow"></span> <span class="arrow"></span>
					</div>
				</div>
				<div class="price-sum">
					<span class="txt">合计:</span>
					 <strong class="price">¥
					<input	name="J_Total" id="J_Total" value="0.00" type="text"/>
					</strong>
				</div>
				<div class="btn-area">
					<a href="#" id="J_Go" class="submit-btn submit-btn-disabled"
						onclick="formSubmit()"> <span>结&nbsp;算</span></a>
				</div>
			</div>
  </form>  
		</div>
           
		<div class="footer">
			<div class="footer-hd">
				<p>
					<a href="#">恒望科技</a> <b>|</b> <a href="#">商城首页</a> <b>|</b> <a
						href="#">支付宝</a> <b>|</b> <a href="#">物流</a>
				</p>
			</div>
			<div class="footer-bd">
				<p>
					<a href="#">关于恒望</a> <a href="#">合作伙伴</a> <a href="#">联系我们</a> <a
						href="#">网站地图</a> <em>© 2015-2025 Hengwang.com 版权所有. 更多模板 <a
						href="http://www.cssmoban.com/" target="_blank" title="模板之家">模板之家</a>
						- Collect from <a href="http://www.cssmoban.com/" title="网页模板"
						target="_blank">网页模板</a></em>
				</p>
			</div>
		</div>

	</div>

	<!--操作页面-->

	<div class="theme-popover-mask"></div>



</body>

</html>